import { prop, modelOptions, arrayProp, Ref } from '@typegoose/typegoose';
import { ApiProperty } from '@nestjs/swagger';
import { Episode } from './episode.model';

// 5-在Typegoose中定义课程和课时的一对多关联
// 课程模型
@modelOptions({
  schemaOptions: {
    timestamps: true
  }
})
export class Course {
  @ApiProperty({ description: '课程名称'})
  @prop()
  name: string

  @ApiProperty({ description: '封面图'})
  @prop()
  // 封面图
  cover: string

  @arrayProp({
    ref: 'Episode'
  })
  episodes: Ref<Episode>[];
}